package charts ;
import flash.display.Sprite;
import flash.geom.Point;
import string.Utils;
import ColorConverter.Color;

class Shape extends Base {
	
	var style: Dynamic;
	
	public function new ( json: Dynamic )
	{
		super();
		this.style = {
			points:				[],
			color:				Hex('#808080'),
			alpha:				0.5
		};
		
		ObjectHelper.merge_2( json, this.style );
		
		this.style.color = string.Utils.get_color( this.style.color );
		
		for ( val in json.values )
			this.style.points.push( new flash.geom.Point( val.x, val.y ) );
	}
	
	public override function resize ( sc:ScreenCoordsBase ): Void {
		
		this.graphics.clear();
		//this.graphics.lineStyle( this.style.width, this.style.color );
		this.graphics.lineStyle( 0, 0, 0 );
		this.graphics.beginFill( this.style.color, this.style.alpha );
		
		var moved:Bool = false;
		
		for ( p in this.style.points ) {
			if( !moved )
				this.graphics.moveTo( sc.get_x_from_val(p.x), sc.get_y_from_val(p.y) );
			else
				this.graphics.lineTo( sc.get_x_from_val(p.x), sc.get_y_from_val(p.y) );
			
			moved = true;
		}
		
		this.graphics.endFill();
	}
}

